-- first.lua

local storyboard = require("storyboard")
local scene = storyboard.newScene()

-- beginning implementation
local widget = require("widget")
local button1, text, group
--called when the scene's view does not exist:
function scene:createScene(event)

	group = self.view
	group:insert(getBackground())
	
	text = display.newText("Waiting for button event...",  display.contentWidth*.1, display.contentHeight * 0.1, display.contentWidth, display.contentHeight * 0.5, native.systemFont, 32)
	group:insert(text)
	
	button1 = widget.newButton{
		label = "Second",
		fontSize = 25,
		labelColor = {default={255,255,255,255},over={255,255,255,255}},
		emboss = false,
		--defaultColor = {60,79,60,255},
		--overColor = {108,142,108,255},
		--width,height = 100,50,
		default = "images/buttonGreen.png",
		over	= "images/buttonGreenOver.png",
		strokeColor = {108,142,108,255},
		cornerRadius = 20
	}
	
	button1.x = display.contentWidth * 0.5; button1.y = display.contentHeight * 0.5
	group:insert(button1)
	
end

--called immediately after scene has moved onscreen:
function scene:enterScene(event)

	local group = self.view
	storyboard.purgeScene( "first" )
	
	-- button handlers
	local button1Press = function(event)
		text:setText("I AM PRESSED AGAIN")
		storyboard.gotoScene( "stategame", "crossFade", 400  )
	end
	
	
	button1:addEventListener("tap", button1Press)
	
end

--called when scene is about to move offscreen:
function scene:exitScene(event)
	local group = self.view
end

--called prior to the removal of scene's "view" (display group)
function scene:destroyScene(event)
	local group = self.view
end

--end implementation

scene:addEventListener("createScene", scene)
scene:addEventListener("enterScene", scene)
scene:addEventListener("destroyScene", scene)

return scene